var e = function(e) {
    return e && e.__esModule ? e : {
        default: e
    };
}(require("../../utils/util")), t = void 0;

Component({
    properties: {
        initData: {
            type: Object,
            value: {},
            observer: function(e) {
                this.setData({
                    initdata: e
                });
            }
        },
        cssIsSidebarShow: {
            type: Boolean,
            value: !1,
            observer: function(e) {
                this.setData({
                    cssIsSidebarShow: e
                });
            }
        },
        cssIsEditable: {
            type: Boolean,
            value: !1,
            observer: function(e) {
                this.setData({
                    cssIseditable: e
                });
            }
        },
        cssIsOnlyShare: {
            type: Boolean,
            value: !1,
            observer: function(e) {
                this.setData({
                    cssIsOnlyShare: e
                });
            }
        },
        isFooterBarShow: {
            type: Boolean,
            value: !1,
            observer: function(e) {
                this.setData({
                    isFooterBarShow: e || !1
                });
            }
        },
        isSharePluginShow: {
            type: Boolean,
            value: !1,
            observer: function(e) {
                this.setData({
                    isSharePluginShow: e
                });
            }
        },
        mode: {
            type: String,
            value: "view",
            observer: function(e) {
                this.setData({
                    mode: e
                });
            }
        },
        origin: {
            type: String,
            value: "site",
            observer: function(e) {
                this.setData({
                    origin: e || "site"
                });
            }
        }
    },
    ready: function() {
        var e = getCurrentPages(), a = getApp().globalData.app;
        t = e[e.length - 1], this.setData({
            app: a
        });
    },
    data: {
        initdata: {},
        isShown: !1,
        isSharePluginShow: !1,
        isFooterBarShow: !1,
        isQrcodeShown: !1,
        qrcodeUrl: ""
    },
    methods: {
        toggleSharePluginsStatus: function() {
            var e = this.data.isSharePluginShow;
            this.setData({
                isSharePluginShow: !e
            });
        },
        showQrcode: function() {
            var t = this, a = this.data, o = a.initdata, s = a.qrcodeUrl, i = a.origin;
            this.setData({
                isQrcodeShown: !0
            }), s || ("site" === i ? e.default.showQrcode(o, "getUrl").then(function(e) {
                t.setData({
                    qrcodeUrl: e
                });
            }) : "groupon" === i ? e.default.getGrouponShareImageUrl(o).then(function(e) {
                t.setData({
                    qrcodeUrl: e
                });
            }) : "bargain" === i ? e.default.getBargainShareImageUrl(o).then(function(e) {
                t.setData({
                    qrcodeUrl: e
                });
            }) : "lottery" === i && e.default.getLotteryShareImageUrl(o).then(function(e) {
                t.setData({
                    qrcodeUrl: e
                });
            }));
        },
        hideQrcode: function() {
            this.setData({
                isQrcodeShown: !1
            });
        },
        saveImage: function() {
            var t = this, a = this.data.qrcodeUrl;
            wx.downloadFile({
                url: a,
                success: function(a) {
                    var o = a.statusCode, s = a.tempFilePath;
                    200 === o && e.default.savePhotoToAlbum(s).then(function() {
                        wx.showToast({
                            title: "保存成功"
                        }), t.setData({
                            isQrcodeShown: !1,
                            isSharePluginShow: !1
                        });
                    });
                }
            });
        },
        hideShareComponent: function() {
            this.setData({
                isQrcodeShown: !1,
                isSharePluginShow: !1
            });
        },
        onShareAppMessage: function() {
            t.onShareAppMessage();
        }
    }
});